package com.llmcu.source.java8.java8inaction.chapter12;

import java.time.LocalDateTime;
import java.time.temporal.ChronoField;

/**
 * 通过with方法创建一个新的修改版本
 *
 * @author liuling
 * @date 2024-12-18 15:11
 */
public class WithMethodDemo {
    public static void main(String[] args) {
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);
        System.out.println(now.withYear(2023));
        System.out.println(now.withMonth(1));
        System.out.println(now.with(ChronoField.HOUR_OF_DAY, 12));
    }
}
